package ru.urfc.portal.ui.client.controllers.loaders;

import ru.urfc.portal.ui.client.Constants;
import ru.urfc.portal.ui.client.controllers.loaders.ConfigurableLoader;

import com.extjs.gxt.ui.client.data.BaseLoader;
import com.extjs.gxt.ui.client.data.DataProxy;

public class SimpleLoader extends BaseLoader<String> implements ConfigurableLoader<String> {

	public SimpleLoader() {
		super((DataProxy<String>)null);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public void setProxy(DataProxy<?> proxy) {
		this.proxy = (DataProxy<String>) proxy;
	}

	@Override
	protected void onLoadFailure(Object loadConfig, Throwable t) {
		if (t.getMessage().matches("HttpProxy. Invalid status code ((204)|(1223))")) {// hacking gxt again
			onLoadSuccess(loadConfig, Constants.HTTP_NO_CONTENT);
			return;
		}
		super.onLoadFailure(loadConfig, t);
	}
	
}
